package ipad.asia.service.discount;

import ipad.asia.entity.Discount;
import ipad.asia.service.discount.fallback.DiscountFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Component
@FeignClient(value = "PROVIDER-PRODUCT",fallback = DiscountFallback.class)
public interface DiscountFeign {

    /**
     * 商品打折
     *
     * @param productId
     * @param setDiscount
     */
    @RequestMapping("/setDiscount/discount/")
    void setDiscount(@RequestParam(value = "productId", required = false) String productId,
                     @RequestParam(value = "setDiscount", required = false) String setDiscount);

    /**
     * 商品降价
     *
     * @param productId
     * @param reduce
     */
    @RequestMapping("/setDiscount/reduce")
    void setReduce(@RequestParam(value = "productId", required = false) String productId,
                   @RequestParam(value = "reduce", required = false) String reduce);

    /**
     * 发布秒杀
     *
     * @param productId
     * @param secKill
     */
    @RequestMapping("/setDiscount/secKill")
    void setSecKill(@RequestParam(value = "productId", required = false) String productId,
                    @RequestParam(value = "secKill", required = false) String secKill);

    /**
     * 发放优惠券
     *
     * @param productId
     * @param coupon
     */
    @RequestMapping("/setDiscount/Coupon")
    void setCoupon(@RequestParam(value = "productId", required = false) String productId,
                   @RequestParam(value = "coupon", required = false) String coupon);

    /**
     * 删除商品优惠
     *
     * @param productId
     */
    @RequestMapping("/delDiscount")
    void delDiscount(@RequestParam(value = "productId", required = false) String productId);

    /**
     * 查询当前商品折扣
     *
     * @param productId
     * @return
     */
    @RequestMapping("/findDiscount/{productId}")
    Discount findDiscount(@PathVariable(value = "productId", required = false) int productId);
}
